package com.guozinhs.auto.util.get;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * JNI字段描述符
 * <p>
 * JavaNative Interface FieldDescriptors
 *
 * @Author: GuoZi
 * @Date: 2022/2/23 9:54
 */
@Getter
@AllArgsConstructor
public enum JNIEnums {

    /**
     * JNI字段描述符
     */
    OBJECT("L", Object.class),
    BOOLEAN("Z", Boolean.class),
    BYTE("B", Byte.class),
    CHARACTER("C", Character.class),
    SHORT("S", Short.class),
    INTEGER("I", Integer.class),
    LONG("J", Long.class),
    FLOAT("F", Float.class),
    DOUBLE("D", Double.class),
    VOID("V", Void.class),
    ARRAY("[", null),
    ;

    private final String key;
    private final Class<?> aClass;

    public static JNIEnums getByKey(String key) {
        for (JNIEnums value : JNIEnums.values()) {
            if (value.getKey().equals(key)) {
                return value;
            }
        }
        return null;
    }

}
